package 练习01_同步查找文件内容;

import java.io.File;

/**
 * @ClassName: TestSearchThread
 * @Author: AllenSun
 * @Date: 2022/3/18 上午1:26
 */
public class TestSearchThread {
    public static void main(String[] args) {
        File folder = new File("/Users/sunzhi/Desktop/修图基地/测试多线程");
        search(folder,"Magic");
    }

    public static void search(File file,String search) {
        if(file.isFile()){
            if(file.getName().toLowerCase().endsWith(".txt")){
                SearchFileThread thread = new SearchFileThread(file,search);
                new Thread(thread).start();
                // new SearchFileThread(file,search).start();
            }
        }
        if(file.isDirectory()){
            File[] fs = file.listFiles();
            for (File f:fs) {
                search(f,search);
            }
        }
    }
}
